package com.tian.clothing.widget.base;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;


/**
 * @ClassName: BaseCustomView
 * @Description: 抽象自定义控件基类
 * @author: dreamfutureba@gmail.com
 * @date: 2013年11月21日 下午4:00:03
 */
public abstract class BaseCustomView extends LinearLayout{

	protected Context mContext;
	protected LayoutInflater mInflater;
	
	public BaseCustomView(Context context) {
		super(context);
		init(context);
	}

	public BaseCustomView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}
	
	protected void init(Context context) {
		this.mContext = context;
		mInflater = LayoutInflater.from(mContext);

		inflateView();
		registerViewEvents();
	}
	
	/**
	 * @Title: setContentView
	 * @Description: 子类在inflateView中调用
	 * @param resLayoutId
	 * @returnType void
	 */
	protected void setContentView(int resLayoutId) {
		mInflater.inflate(resLayoutId, this);
	}
	
	/**
	 * @Title: inflateView
	 * @Description: 解析View
	 * @returnType void
	 */
	protected abstract void inflateView();

	/**
	 * @Title: registerViewEvents
	 * @Description: 注册View的事件
	 * @returnType void
	 */
	protected abstract void registerViewEvents();

}
